package com.sline.servlet.demo2_cookie_session;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/session/inbox")
public class inbox extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html; charset=UTF-8");

        HttpSession session = req.getSession();
        String username = (String) session.getAttribute("username");

        PrintWriter writer = resp.getWriter();
        writer.println("尊敬的: " + username);
        writer.println("<a href='/servlet/session/mailDetail'>收件箱</a>");
        writer.println("<a href='/servlet/session/mailDetail'>收件箱</a>");
        writer.println("<a href='/servlet/session/mailDetail'>收件箱</a>");
    }
}
